TypeCache.cpp
Language: C++
Last Modified: 2022-08-18 12:03:01 AM UTC
File Size: 844 bytes
Last Modified: 2022-08-18 12:03:01 AM UTC
File Size: 844 bytes
http://www.penguinstew.ca/example/CodeFormater/TypeCache.cpp
#include "TypeCache.h"
TypeCache::TypeCache()
{
types = std::vector<Type>();
langs = std::vector<Lang>();
}
Type TypeCache::LoadLanguage(std::string type)
{
for (unsigned int i = 0; i < type.length(); i++)
{
type[i] = tolower(type[i]);
}
for (unsigned int i = 0; i < types.size(); i++)
{
Type t = types.at(i);
if (t.GetExt().compare(type) == 0)
{
return t;
}
}
Type t = Type(type);
types.push_back(t);
for (unsigned int i = 0; i < t.GetLangs().size(); i++)
{
Lang l = t.GetLangs().at(i);
langs.push_back(l);
}
return t;
}
Lang* TypeCache::FindStartLang(std::string line, int pos, TypeIdPair typeId)
{
for (unsigned int i = 0; i < langs.size(); i++)
{
Lang* l = &langs.at(i);
if (l->IsStart(line, pos, typeId))
{
return l;
}
}
return NULL;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49